//检查基本信息
function checkBasic(oForm) {
    var name = str_trim($(oForm).find('#name').val());
    if (name == '') {
        layerMsg('用户名不能为空!', 2);
        $(oForm).find('#name').focus();
        $(oForm).find('#name').val(name);
        return false;
    }
    if ($(oForm).find('#sex').val() == '') {
        layerMsg('请选择性别!', 2);
        return false;
    }
    if ($(oForm).find('#birthday').val() == '') {
        layerMsg('请选择出生日期!', 2);
        return false;
    }
    if ($(oForm).find('#education').val() == '') {
        layerMsg('请选择最高学历!', 2);
        return false;
    }

    if ($(oForm).find('#work_year').val() == '') {
        layerMsg('请选择工作经验!', 2);
        return false;
    }
    if ($(oForm).find('#job_status').val() == '') {
        layerMsg('请选择求职状态!', 2);
        return false;
    }
    if ($(oForm).find('#homeaddress').val() == '') {
        layerMsg('请选择现居地!', 2);
        return false;
    }
    var mobile = str_trim($(oForm).find('#mobile').val());
    if( mobile == ''){
        layerMsg('手机号码不能为空!',2);
        $(oForm).find('#mobile').focus();
        $(oForm).find('#mobile').val(mobile);
        return false;
    }else if( mobile  != '' ) {
        var regu =/(^1[3-9]{1}[0-9]{9}$)/g;
        if(!regu.test(mobile)){
            layerMsg('请输入正确的手机号码!',2);
            $(oForm).find('#mobile').focus();
            $(oForm).find('#mobile').val(mobile);
            return false;
        }
    }
    var email = str_trim($(oForm).find('#email').val());
    if(email != ''){
        var regu =/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        if (!regu.test(email)){
            layerMsg('请输入正确的邮箱地址!',2);
            $(oForm).find('#email').focus();
            $(oForm).find('#email').val(email);
            return false;
        }
    }
    if ($(oForm).find('#census').val() == '') {
        layerMsg('请选择户籍!', 2);
        return false;
    }
    if ($(oForm).find('#marital').val() == '') {
        layerMsg('请选择婚姻状况!', 2);
        return false;
    }
    var height = str_trim($(oForm).find('#height').val());
    if(height != ''){
        var regu =/(^[1-9]{1}[0-9]{1,2}$)/g;
        if (!regu.test(height)){
            layerMsg('请输入正确的身高!',2);
            $(oForm).find('#height').focus();
            $(oForm).find('#height').val(height);
            return false;
        }
    }
    return true;
}

//检查求职意向
function checkObjective(oForm) {
    var intentionjobs = str_trim($(oForm).find('#intentionjobs').val());
    if (intentionjobs == '') {
        layerMsg('意向岗位不能为空!', 2);
        $(oForm).find('#intentionjobs').focus();
        $(oForm).find('#intentionjobs').val(intentionjobs);
        return false;
    }
    if ($(oForm).find('#jobarea1').val() == '') {
        layerMsg('请选择工作地区!', 2);
        return false;
    }
    if ($(oForm).find('#jobsort1').val() == '') {
        layerMsg('请选择期望职位!', 2);
        return false;
    }
    return true;
}

//检查工作经历
function checkWork(oForm) {
    var company = str_trim($(oForm).find('#company').val());
    if (company == '') {
        layerMsg('公司名称不能为空!', 2);
        $(oForm).find('#company').focus();
        $(oForm).find('#company').val(company);
        return false;
    }
    if ($(oForm).find('#comkind').val() == '') {
        layerMsg('请选择公司性质!', 2);
        return false;
    }
    if ($(oForm).find('#scale').val() == '') {
        layerMsg('请选择企业规模!', 2);
        return false;
    }
    if ($(oForm).find('#industry').val() == '') {
        layerMsg('请选择所属行业!', 2);
        return false;
    }
    var starttime = $(oForm).find('#starttime').val();
    var endtime = $(oForm).find('#endtime').val();
    if (starttime=="" || starttime=="0"){
        layerMsg('请选择开始年份!', 2);
        return false;
    }else{
        if(endtime!= "" && endtime!= "0000-00-00" ){
            if (starttime > endtime){
                layerMsg('开始年份不能大于结束年份!', 2);
                return false;
            }
        }else if(endtime=="" || endtime=="0"){
            layerMsg('请选择结束年份!', 2);
            return false;
        }
    }
    var post = str_trim($(oForm).find('#post').val());
    if (post == '') {
        layerMsg('职位名称不能为空!', 2);
        $(oForm).find('#post').focus();
        $(oForm).find('#post').val(post);
        return false;
    }
    $(oForm).find("input[type='submit']").val('保存中...');
    $(oForm).find("input[type='submit']").attr('disabled', true);
    return true;
}

//检查教育经历
function checkEdu(oForm) {
    var school = str_trim($(oForm).find('#school').val());
    if (school == '') {
        layerMsg('学校名称不能为空!', 2);
        $(oForm).find('#school').focus();
        $(oForm).find('#school').val(school);
        return false;
    }
    if ($(oForm).find('#education').val() == '') {
        layerMsg('请选择最高学历!', 2);
        return false;
    }
    var starttime = $(oForm).find('#starttime').val();
    var endtime = $(oForm).find('#endtime').val();
    if (starttime=="" || starttime=="0"){
        layerMsg('请选择开始年份!', 2);
        return false;
    }else{
        if(endtime!= "" && endtime!= "0000-00-00" ){
            if (starttime > endtime){
                layerMsg('开始年份不能大于结束年份!', 2);
                return false;
            }
        }else if(endtime=="" || endtime=="0"){
            layerMsg('请选择结束年份!', 2);
            return false;
        }
    }
    var speciality = str_trim($(oForm).find('#speciality').val());
    if (speciality == '') {
        layerMsg('专业名称不能为空!', 2);
        $(oForm).find('#speciality').focus();
        $(oForm).find('#speciality').val(speciality);
        return false;
    }
    $(oForm).find("input[type='submit']").val('保存中...');
    $(oForm).find("input[type='submit']").attr('disabled', true);
    return true;
}

//检查培训经历
function checkTrain(oForm) {
    var school = str_trim($(oForm).find('#school').val());
    if (school == '') {
        layerMsg('培训机构不能为空!', 2);
        $(oForm).find('#school').focus();
        $(oForm).find('#school').val(school);
        return false;
    }
    var starttime = $(oForm).find('#starttime').val();
    var endtime = $(oForm).find('#endtime').val();
    if (starttime=="" || starttime=="0"){
        layerMsg('请选择开始年份!', 2);
        return false;
    }else{
        if(endtime!= "" && endtime!= "0000-00-00" ){
            if (starttime > endtime){
                layerMsg('开始年份不能大于结束年份!', 2);
                return false;
            }
        }else if(endtime=="" || endtime=="0"){
            layerMsg('请选择结束年份!', 2);
            return false;
        }
    }
    var speciality = str_trim($(oForm).find('#speciality').val());
    if (speciality == '') {
        layerMsg('培训项目不能为空!', 2);
        $(oForm).find('#speciality').focus();
        $(oForm).find('#speciality').val(speciality);
        return false;
    }
    $(oForm).find("input[type='submit']").val('保存中...');
    $(oForm).find("input[type='submit']").attr('disabled', true);
    return true;
}

//检查项目经验
function checkProject(oForm) {
    var project_name = str_trim($(oForm).find('#project_name').val());
    if (project_name == '') {
        layerMsg('项目名称不能为空!', 2);
        $(oForm).find('#project_name').focus();
        $(oForm).find('#project_name').val(project_name);
        return false;
    }
    var starttime = $(oForm).find('#starttime').val();
    var endtime = $(oForm).find('#endtime').val();
    if (starttime=="" || starttime=="0"){
        layerMsg('请选择开始年份!', 2);
        return false;
    }else{
        if(endtime!= "" && endtime!= "0000-00-00" ){
            if (starttime > endtime){
                layerMsg('开始年份不能大于结束年份!', 2);
                return false;
            }
        }else if(endtime=="" || endtime=="0"){
            layerMsg('请选择结束年份!', 2);
            return false;
        }
    }
    var post = str_trim($(oForm).find('#post').val());
    if (post == '') {
        layerMsg('职务名称不能为空!', 2);
        $(oForm).find('#post').focus();
        $(oForm).find('#post').val(post);
        return false;
    }
    $(oForm).find("input[type='submit']").val('保存中...');
    $(oForm).find("input[type='submit']").attr('disabled', true);
    return true;
}

//检查语言能力
function checkLanguage(oForm,url) {
    if ($(oForm).find('#language').val() == '') {
        layerMsg('请选择语种!', 2);
        return false;
    }
    if ($(oForm).find('#degree').val() == '') {
        layerMsg('请选择熟练程度!', 2);
        return false;
    }
    var serialize = $(oForm).serialize();
    $.ajax({
        url: url,
        dataType: "json",
        data: serialize,
        type: "POST",
        beforeSend: function () {
            $(oForm).find("input[type='submit']").val('请稍候...');
            $(oForm).find("input[type='submit']").attr('disabled', true);
        },
        success: function (data) {
            if(data.status == '0'){
                layerMsg(data.msg,2);
                $(oForm).find("input[type='submit']").val('保存');
                $(oForm).find("input[type='submit']").removeAttr('disabled');
            }else if(data.status == '1'){
                layerMsg(data.msg,0);
                location = '/mobile/personal/resume_manage?parameter=language&resume_id='+data.resume_id;
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr += "<p style='line-height: .4rem; width: 100%'>"+ value+";</p>";
            });
            layerMsg(msgErr,2);
            $(oForm).find("input[type='submit']").val('保存');
            $(oForm).find("input[type='submit']").removeAttr('disabled');
        }
    });
    return false;
}

//检查技能专长
function checkSkill(oForm,url) {
    var skillname = str_trim($(oForm).find('#skillname').val());
    if (skillname == '') {
        layerMsg('技能名称不能为空!', 2);
        $(oForm).find('#skillname').focus();
        $(oForm).find('#skillname').val(skillname);
        return false;
    }
    if ($(oForm).find('#degree').val() == '') {
        layerMsg('请选择熟练程度!', 2);
        return false;
    }
    var serialize = $(oForm).serialize();
    $.ajax({
        url: url,
        dataType: "json",
        data: serialize,
        type: "POST",
        beforeSend: function () {
            $(oForm).find("input[type='submit']").val('请稍候...');
            $(oForm).find("input[type='submit']").attr('disabled', true);
        },
        success: function (data) {
            if(data.status == '0'){
                layerMsg(data.msg,2);
                $(oForm).find("input[type='submit']").val('保存');
                $(oForm).find("input[type='submit']").removeAttr('disabled');
            }else if(data.status == '1'){
                layerMsg(data.msg,0);
                location = '/mobile/personal/resume_manage?parameter=skill&resume_id='+data.resume_id;
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr += "<p style='line-height: .4rem; width: 100%'>"+ value+";</p>";
            });
            layerMsg(msgErr,2);
            $(oForm).find("input[type='submit']").val('保存');
            $(oForm).find("input[type='submit']").removeAttr('disabled');
        }
    });
    return false;
}

//检查证书
function checkCertificate(oForm,url) {
    var certificate_name = str_trim($(oForm).find('#certificate_name').val());
    if (certificate_name == '') {
        layerMsg('证书名称不能为空!', 2);
        $(oForm).find('#certificate_name').focus();
        $(oForm).find('#certificate_name').val(certificate_name);
        return false;
    }
    if ($(oForm).find('#gettime').val() == '') {
        layerMsg('请选择获得时间!', 2);
        return false;
    }
    var serialize = $(oForm).serialize();
    $.ajax({
        url: url,
        dataType: "json",
        data: serialize,
        type: "POST",
        beforeSend: function () {
            $(oForm).find("input[type='submit']").val('请稍候...');
            $(oForm).find("input[type='submit']").attr('disabled', true);
        },
        success: function (data) {
            if(data.status == '0'){
                layerMsg(data.msg,2);
                $(oForm).find("input[type='submit']").val('保存');
                $(oForm).find("input[type='submit']").removeAttr('disabled');
            }else if(data.status == '1'){
                layerMsg(data.msg,0);
                location = '/mobile/personal/resume_manage?parameter=certificate&resume_id='+data.resume_id;
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr += "<p style='line-height: .4rem; width: 100%'>"+ value+";</p>";
            });
            layerMsg(msgErr,2);
            $(oForm).find("input[type='submit']").val('保存');
            $(oForm).find("input[type='submit']").removeAttr('disabled');
        }
    });
    return false;
}

//其它信息
function checkOther(oForm,url) {
    if ($(oForm).find('#title').val() == '' && $(oForm).find('#title').val() != 'zdy') {
        layerMsg('请选择主题!', 2);
        return false;
    }else if($(oForm).find('#title').val() == 'zdy'){
        var titInp = str_trim($(oForm).find('#titInp').val());
        if (titInp == '') {
            layerMsg('主题名称不能为空!', 2);
            $(oForm).find('#titInp').focus();
            $(oForm).find('#titInp').val(titInp);
            return false;
        }
    }
    if ($(oForm).find('#content').html() == '') {
        layerMsg('请填写内容描述!', 2);
        return false;
    }

    var serialize = $(oForm).serialize();
    $.ajax({
        url: url,
        dataType: "json",
        data: serialize,
        type: "POST",
        beforeSend: function () {
            $(oForm).find("input[type='submit']").val('请稍候...');
            $(oForm).find("input[type='submit']").attr('disabled', true);
        },
        success: function (data) {
            if(data.status == '0'){
                layerMsg(data.msg,2);
                $(oForm).find("input[type='submit']").val('保存');
                $(oForm).find("input[type='submit']").removeAttr('disabled');
            }else if(data.status == '1'){
                layerMsg(data.msg,0);
                location = '/mobile/personal/resume_manage?parameter=other&resume_id='+data.resume_id;
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr += "<p style='line-height: .4rem; width: 100%'>"+ value+";</p>";
            });
            layerMsg(msgErr,2);
            $(oForm).find("input[type='submit']").val('保存');
            $(oForm).find("input[type='submit']").removeAttr('disabled');
        }
    });
    return false;
}

//作品
function checkWorks(oForm,url) {
    var works_name = str_trim($(oForm).find('#works_name').val());
    if (works_name == '') {
        layerMsg('作品名称不能为空!', 2);
        $(oForm).find('#works_name').focus();
        $(oForm).find('#works_name').val(works_name);
        return false;
    }
    if ($(oForm).find('#description').html() == '') {
        layerMsg('请填写作品描述!', 2);
        return false;
    }

    var serialize = $(oForm).serialize();
    $.ajax({
        url: url,
        dataType: "json",
        data: serialize,
        type: "POST",
        beforeSend: function () {
            $(oForm).find("input[type='submit']").val('请稍候...');
            $(oForm).find("input[type='submit']").attr('disabled', true);
        },
        success: function (data) {
            if(data.status == '11'){
                layerMsg(data.msg,2);
                $(oForm).find("input[type='submit']").val('保存');
                $(oForm).find("input[type='submit']").removeAttr('disabled');
            }else if(data.status == '10'){
                layerMsg(data.msg,0);
                location = '/mobile/personal/resume_manage?parameter=works&resume_id='+data.resume_id;
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr += "<p style='line-height: .4rem; width: 100%'>"+ value+";</p>";
            });
            layerMsg(msgErr,2);
            $(oForm).find("input[type='submit']").val('保存');
            $(oForm).find("input[type='submit']").removeAttr('disabled');
        }
    });
    return false;
}

//删除列表
function delList(id,text,url,parameter,resume_id){
    layer.open({
        className : 'textarea_content' //自定风格
        ,content: '您确定要删除这个'+text+'吗？'
        ,style: 'font-family:微软雅黑; font-size:.28rem'
        ,btn: ['确认', '取消']
        ,yes: function(index){
            $.post(url, {'id':id,'_token': _token}, function (data) {
                if (data.status == 0) {
                    location.href = '/mobile/personal/resume_manage?parameter='+parameter+'&resume_id='+resume_id;
                    layerMsg(data.msg,1);
                } else {
                    layerMsg(data.msg,2);
                }
            });
        }
    });
}